<?php

require_once "config.php";
require_once "autoload.php";

//禁止报错
error_reporting(E_ERROR | E_WARNING | E_PARSE);

if ($_GET['ip']) {
    $ip = $_GET['ip'];
} else {
    $ip = app\MyIP::query();
}

$info = app\QueryIP::query($ip);

if ($info) {
    $date = $info;
    $date['code'] = 200;
} else {
    $date['code'] = 400;
    $date['msg'] = '号码不正确！';
}

if (!$date['code'] == 200) {
    die($date['msg']);
}
?>
<table id="ip-info">
    <tr>
        <td>IP地址：</td>
        <td id="ip-number"><?php echo $info['ip']; ?></td>
    </tr>
    <tr>
        <td>国家：</td>
        <td id="ip-country"><?php echo $info['country']; ?></td>
    </tr>
    <tr>
        <td>省份：</td>
        <td id="ip-province"><?php echo $info['province']; ?></td>
    </tr>
    <tr>
        <td>城市：</td>
        <td id="ip-city"><?php echo $info['city']; ?></td>
    </tr>
    <tr>
        <td>区域：</td>
        <td id="ip-district"><?php echo $info['district']; ?></td>
    </tr>
    <tr>
        <td>运营商：</td>
        <td id="ip-carrier"><?php echo $info['carrier']; ?></td>
    </tr>
    <tr>
        <td>其他：</td>
        <td id="ip-msg"><?php echo $info['msg']; ?></td>
    </tr>
</table>

